package com.lipaluma.parser.builder;

import java.lang.reflect.Field;
import java.util.Locale;

import com.lipaluma.field.mapper.FieldMapper;
import com.lipaluma.field.mapper.builder.InitMappingBuilder;
import com.lipaluma.field.mapper.mapping.FieldMappingInfo;
import com.lipaluma.parser.AbstractDataParser;
import com.lipaluma.parser.DataParser;

public class FromParserInitMappingBuilder<BUILDER extends AbstractDataParser.Builder<? extends DataParser<TARGET>, TARGET>, TARGET> {
	private InitMappingBuilder delegate;
	private FromParserFieldMapperBuilder<BUILDER, TARGET> parent;
	
	public FromParserInitMappingBuilder(FromParserFieldMapperBuilder<BUILDER, TARGET> parent, FieldMapper fieldMapper, Field field) {
		this.parent = parent;
		this.delegate = new InitMappingBuilder(parent.getContext(), fieldMapper, field);
	}
	
	public FromParserInitMappingBuilder<BUILDER, TARGET> on(FieldMappingInfo... mappings) {
		delegate.on(mappings);
		return this;
	}
	public FromParserInitMappingBuilder<BUILDER, TARGET> withPattern(String pattern) {
		delegate.withPattern(pattern);
		return this;
	}
	public FromParserInitMappingBuilder<BUILDER, TARGET> withSeparator(String separator){
		delegate.withSeparator(separator);
		return this;
	}
	public FromParserInitMappingBuilder<BUILDER, TARGET> withTrueValues(String... trueValues){
		delegate.withTrueValues(trueValues);
		return this;
	}
	public FromParserInitMappingBuilder<BUILDER, TARGET> withFalseValues(String... falseValues){
		delegate.withFalseValues(falseValues);
		return this;
	}
	public FromParserInitMappingBuilder<BUILDER, TARGET> withLocale(Locale locale){
		delegate.withLocale(locale);
		return this;
	}
	public FromParserInitMappingBuilder<BUILDER, TARGET> keepAll() {
		delegate.keepAll();
		return this;
	}
	public FromParserFieldMapperAfterRegisterBuilder<BUILDER, TARGET> endMap() {
		delegate.endMap();
		return parent;
	}
}
